package com.scm.ingestion;

import java.io.IOException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.log4j.Logger;
import com.scm.property.PropertyConfig;
import com.scm.property.IPropertyConfig;


public class ProtocolSecret {
	
	private static Logger log = Logger.getLogger(ProtocolSecret.class);

	
	public static String getSecretId(HttpClient client) {
		IPropertyConfig property = new PropertyConfig();
		String url = property.getStringIngestionUrl("service.php");
	//	log.info("REQUEST:"+url);
		PostMethod method = new PostMethod(url);
		method.setParameter("secret",property.getStringSecretKey());
		method.setParameter("token",property.getStringTokenKey());
		String response = null;
		try {
			client.executeMethod(method);
			response = method.getResponseBodyAsString();
	//		log.info("SECRET KEY:"+response);
			method.releaseConnection();
		} catch (HttpException e) {
			log.error("HttpException:",e);
		} catch (IOException e) {
			log.error("IOException:",e);
		}
		return response;
	}

}
